package com.hubing.cloud.app.web.es.query;

public class RegexpQueryBuilder extends AbstractQueryBuilder<RegexpQueryBuilder> {

	private final String fieldName;
	private final String regexp;

	public RegexpQueryBuilder(String name, String regexp) {
		this.fieldName = name;
		this.regexp = regexp;
	}

	@Override
	public String toDocument() {
		return String.format("{" + " \"regexp\":{" + "   \"%s\":\"%s\"" + "  }" + "}", fieldName, regexp);
	}

	@Override
	public String toString() {
		return toDocument();
	}
}
